<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 环绕字符串中唯一的子字符串 -->
    <script>
      var findSubstringInWraproundString = function (p) {
        const dp = new Array(26).fill(0)
        let num = 0
        for (let i = 0; i < p.length; i++) {
          i > 0 && (p[i].charCodeAt() - p[i - 1].charCodeAt() + 26) % 26 == 1 ? num++ : (num = 1)
          let ind = p[i].charCodeAt() - 97
          dp[ind] = Math.max(dp[ind], num)
        }
        return dp.reduce((a, b) => a + b)
      }
      console.log(findSubstringInWraproundString('zab'))
    </script>
  </body>
</html>
